//package org.ruoyi.chat.service.chat.impl;
//
//import jakarta.servlet.http.HttpServletRequest;
//import org.ruoyi.chat.service.chat.WebSocketChatService;
//import org.ruoyi.common.chat.handler.WebSocketMessageHandler;
//import org.ruoyi.common.chat.request.ChatRequest;
//import org.springframework.web.socket.WebSocketSession;
//
//import java.io.IOException;
//import java.util.function.Consumer;
//
//public class WebSocketChatServiceImpl implements WebSocketChatService, WebSocketMessageHandler {
//    @Override
//    public void handleWebSocketChat(ChatRequest chatRequest, Consumer<String> messageConsumer) {
//        // 模拟 AI 流式回答
//        String[] chunks = {"这是", "流式", "回答"};
//        for (String chunk : chunks) {
//            messageConsumer.accept(chunk);
//            try {
//                // 模拟处理延迟
//                Thread.sleep(500);
//            } catch (InterruptedException e) {
//                Thread.currentThread().interrupt();
//            }
//        }
//    }
//
//    @Override
//    public void handleChatMessage(ChatRequest chatRequest, HttpServletRequest request, WebSocketSession session) throws IOException {
//
//    }
//}
